/**	\author    coidgen 0.9.2
	\version    (27.0 build 81)
	\date      
	\brief     
*/

#ifndef __COID_CLIENT__example_h
#define __COID_CLIENT__example_h


#define CLIENT__example_h



#include "coid/coidclient.h"
#include "coid/comm/sync/mutex_reg.h"


extern const version COID_version_TestClass_27_0;


 
#include "coid/comm/binstream/stlstream.h"

 
#include <vector>

 
struct calculator	//structure for easy web calculator
{
	float number_in;
	float score;
	std::string operation;

	friend binstream & operator << ( binstream & out, const calculator & x ) 	
	{ 
		return out << x.number_in << x.score << x.operation; 
	};

    friend binstream & operator >> ( binstream & in, calculator & x ) 
	{
		return in >> x.number_in >> x.score >> x.operation;      /// notice the FIFO order (first in, first out)
    };

	friend metastream& operator << ( metastream& m, const calculator & x )
    {
        MSTRUCT_OPEN(m,"operation");
		MM(m,"number_in",x.number_in);
		MM(m,"score",x.score);
		MM(m,"operation",x.operation);
		MSTRUCT_CLOSE(m);
    }
};

 
struct birth_date
{
	int day;
	int month;
	int year;

	friend binstream & operator << ( binstream & out, const birth_date & x ) 	
	{ 
		return out << x.day << x.month << x.year; 
	};

    friend binstream & operator >> ( binstream & in, birth_date & x ) 
	{
		return in >> x.day >> x.month >> x.year;      /// notice the FIFO order (first in, first out)
    };

	friend metastream& operator << ( metastream& m, const birth_date & x )
    {
        MSTRUCT_OPEN(m,"birth_date");
		MM(m,"day",x.day);
		MM(m,"month",x.month);
		MM(m,"year",x.year);
		MSTRUCT_CLOSE(m);
    }
};

 
struct login_inf
{
	std::string login_name;
	std::string password;
	std::string retype_password;

	friend binstream & operator << ( binstream & out, const login_inf & x ) 	
	{ 
		return out << x.login_name << x.password << x.retype_password; 
	};

    friend binstream & operator >> ( binstream & in, login_inf & x ) 
	{
		return in >> x.login_name >> x.password >> x.retype_password;      /// notice the FIFO order (first in, first out)
    };

	friend metastream& operator << ( metastream& m, const login_inf & x )
    {
        MSTRUCT_OPEN(m,"login_inf");
		MM(m,"login_name",x.login_name);
		MM(m,"password",x.password);
		MM(m,"retype_password",x.retype_password);
		MSTRUCT_CLOSE(m);
    }

};

 
struct address_struct
{
	std::string street;
	std::string	city;
	std::string state;
	std::string zip;

	friend binstream & operator << ( binstream & out, const address_struct & x ) 	
	{ 
		return out << x.street << x.city << x.state << x.zip; 
	};

    friend binstream & operator >> ( binstream & in, address_struct & x ) 
	{
		return in >> x.street >> x.city >> x.state >> x.zip;      /// notice the FIFO order (first in, first out)
    };

	friend metastream& operator << ( metastream& m, const address_struct & x )
    {
        MSTRUCT_OPEN(m,"address");
		MM(m,"street",x.street);
		MM(m,"city",x.city);
		MM(m,"state",x.state);
		MM(m,"zip",x.zip);
		MSTRUCT_CLOSE(m);
    }

};

 
struct person
{
	std::string title;
	std::string name;
	std::string surname;
	address_struct address;
	login_inf login_information;
	birth_date birth_information;

	friend binstream & operator << ( binstream & out, const person & x ) 	
	{ 
		return out << x.title << x.name << x.surname << x.address << x.login_information << x.birth_information; 
	};

    friend binstream & operator >> ( binstream & in, person & x ) 
	{
		return in >> x.title  >> x.name >> x.surname >> x.address >> x.login_information >> x.birth_information;      /// notice the FIFO order (first in, first out)
    };

    friend metastream& operator << ( metastream& m, const person & x )
    {
        MSTRUCT_OPEN(m,"person");
		MM(m,"title",x.title);
		MM(m,"name",x.name);
		MM(m,"surname",x.surname);
		MM(m,"address",x.address);
		MM(m,"login_inforamtion",x.login_information);
		MM(m,"birth_information",x.birth_information);
        MSTRUCT_CLOSE(m);
    }

};

struct trivTypes
{
	float	a;
	int		b;
	char	c;


    friend binstream & operator << ( binstream & out, const trivTypes & x ) 	
	{ 
		return out << x.a << x.b << x.c; 
	};

    friend binstream & operator >> ( binstream & in, trivTypes & x ) 
	{
        return in >> x.a  >> x.b >> x.c;      /// notice the FIFO order (first in, first out)
    };

    friend metastream& operator << ( metastream& m, const trivTypes& x )
    {
        MSTRUCT_OPEN(m,"trivTypes");
        MM(m,"a",x.a);
        MM(m,"b",x.b);
        MM(m,"c",x.c);
        MSTRUCT_CLOSE(m);
    }
};

struct color
{
	int col1;
	int col2;
	trivTypes tt;
	
	friend binstream & operator << ( binstream & out, const color & x ) 	
	{ 
		return out << x.col1 << x.col2 <<x.tt; 
	};

    friend binstream & operator >> ( binstream & in, color & x ) 
	{											
		return in >> x.col1  >> x.col2 >> x.tt;      /// notice the FIFO order (first in, first out)
    };

    friend metastream& operator << ( metastream& m, const color& x )
    {
        MSTRUCT_OPEN(m,"color");
		MM(m,"col1",x.col1);
		MM(m,"col2",x.col2);
		MM(m,"tt", x.tt);
		MSTRUCT_CLOSE(m);
    }
} ;

struct easy
{
	int num1;
	float num2;
	std::string label;
	color somecolor;
	std::vector<color> colorVector;


	friend binstream & operator << ( binstream & out, const easy & x ) 	
	{ 
		return out << x.num1 << x.num2 << x.label << x.somecolor << x.colorVector; 
	};

    friend binstream & operator >> ( binstream & in, easy & x ) 
	{											
		return in >> x.num1  >> x.num2 >> x.label >> x.somecolor >> x.colorVector;      /// notice the FIFO order (first in, first out)
    };

    friend metastream& operator << ( metastream& m, const easy& x )
    {
        MSTRUCT_OPEN(m,"easy");
        MM(m,"num1",x.num1);
        MM(m,"num2",x.num2);
		MM(m,"label",x.label);
		MM(m,"someColor",x.somecolor);
		MM(m,"colorVector", x.colorVector);
		MSTRUCT_CLOSE(m);
    }
} ;

struct cmplx
{
	float value;
	std::string label;
	int number;
	easy structure;

	friend binstream & operator << ( binstream & out, const cmplx & x ) 	
	{ 
		return out << x.value << x.label << x.number << x.structure; 
	};

    friend binstream & operator >> ( binstream & in, cmplx & x ) 
	{											
		return in >> x.value  >> x.label >> x.number >> x.structure;      /// notice the FIFO order (first in, first out)
    };

    friend metastream& operator << ( metastream& m, const cmplx& x )
    {
        MSTRUCT_OPEN(m,"cmplx");
        MM(m,"value",x.value);
        MM(m,"label",x.label);
		MM(m,"number",x.number);
		MM(m,"structure",x.structure);
		MSTRUCT_CLOSE(m);
    }
} ;

 
struct vector_of_cmplx
{
	std::vector<cmplx> vector;
	
	friend binstream & operator << ( binstream & out, const vector_of_cmplx & x ) 	
	{ 
		return out << x.vector; 
	};

    friend binstream & operator >> ( binstream & in, vector_of_cmplx & x ) 
	{											
		return in >> x.vector;      /// notice the FIFO order (first in, first out)
    };

    friend metastream& operator << ( metastream& m, const vector_of_cmplx& x )
    {
        MSTRUCT_OPEN(m,"vector_of_cmplx");
		MM(m,"vector",x.vector);
		MSTRUCT_CLOSE(m);
    }
} ;




namespace coid {


struct COID_TABLE_TestClass_27_0;


class TestClass_client
{
private:
	COID_TABLE_TestClass_27_0 * _me;
	COID_TABLE_TestClass_27_0 * _vtbl;
	mutable comm_mutex_custom_reg<netstream, void*> _mx_reg;
	uint _conn_data;
	uint _timeout;
	charstr _addr;

	void set_connection_type( uint ct ) {_conn_data = ct;}
	void destroy_me();

public:
	TestClass_client();
	~TestClass_client();
	TestClass_client( const TestClass_client & c );
	TestClass_client & operator = ( const TestClass_client & c );

	opcd ping_server( const char * coid_address, uint coid_obj_id=UMAX, uint coid_flags=ConnectFlags::xACCESS_MODE ) const;
	bool is_connected() const {return _me != NULL;}
	opcd disconnect();
	const charstr& get_addr() const {return _addr;}
	comm_mutex_reg * get_mx() {return &_mx_reg;}
	opcd get_last_error() const;
	void set_last_error( opcd e );
	uint get_connection_type() const {return _conn_data;}
	opcd set_timeout( uint milliseconds );
	uint get_timeout() const {return _timeout;}
	void setup_stream( binstream& b, uint coid_flags, uint coid_obj_id ) const;
	bool setup_members( uint coid_stream_flags, netstream * bstream, binstream * bstream2=NULL, comm_mutex_reg * mx_reg=NULL );

	static const version & get_version() { return COID_version_TestClass_27_0; }


public:
	opcd connect( int status_init, const char * coid_address=NULL, uint coid_flags=ConnectFlags::xACCESS_MODE );
	opcd connect_within( comm_mutex_reg & coid_channel, int status_init );
	opcd connect_shared( uint coid_obj_id,  const char * coid_address=NULL, uint coid_flags=ConnectFlags::xACCESS_MODE  );

	// returns 'length' of 'str'
	opcd get_length( int & length, const std::string & str );
	//returns length of vector 
	opcd get_vect_length( int & length, const std::vector<trivTypes> & vec );
	// multiplies 'a' and 'b' and returns 'result'
	opcd multiply( double a, double b, double & result );
	// multiplies 'a' and 'b' and returns 'result'
	opcd add_one( int & number );
	// sets 'status' variable
	opcd set_status( int & old_status, int new_status );
	opcd set_birth_date(std::vector< birth_date > & birt_d);
	// returns 'cmplx'
	opcd cmplx_meth(std::vector<cmplx> & smthg_out, color & colorstruct, int & number_out);
	opcd cmplx_meth_in(std::vector<cmplx> & smthg_in, color & colorstruct, int & number_in);
	opcd array_of_int(std::vector<int> int_array);
	// returns vector of strings
	opcd get_string_vector( std::vector<std::string> & string_vector_out );
	// sets vector of strings
	opcd set_string_vector( std::vector<std::string> & string_vector_in );
	// sets vector of vector of cmplx and vector of vector of trivTypes
	opcd set_vv_cmplx_and_trivType( std::vector<std::vector<cmplx> > & vv_cmplx_in, std::vector<std::vector<trivTypes> > & vv_trivTypes_in );
	// returns vector of vector of cmplx and vector of vector of trivTypes
	opcd get_vv_cmplx_and_trivType( std::vector<std::vector<cmplx> > & vv_cmplx_out, std::vector<std::vector<trivTypes> > & vv_trivTypes_out );
	// sets personal data
	opcd set_personal_data( person & person_in_out );
	// sets address
	opcd set_address( address_struct & address );
	//use as calculator
	opcd calculate( calculator & calcul_in_out );
};

} // namespace coid


#endif	// ! __COID_CLIENT__example_h
